package cn.zqh.brand.controller;


import cn.zqh.bean.api.CommonResult;
import cn.zqh.brand.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zqh
 * @since 2023-03-01
 */
@RestController
@RequestMapping("/order")
@Api("OrderController")
public class OrderController {

    @Autowired
    private OrderService orderService;


    /**
      * @Author: zqh
      * @Date:
      * @Description: 购买商品
    */
    @ApiOperation(value = "商品购买(添加订单)")
    @PostMapping("buyACommodity")
    public CommonResult buyACommodity(String commodityId,Integer number){
        return orderService.buyACommodity(commodityId,number);
    }
    
    /**
      * @Author: zqh
      * @Date: 
      * @Description: 把购物车里的商品提交订单
    */
    @ApiOperation(value = "把购物车里的商品提交订单")
    @PostMapping("submitTheorderForCart")
    public CommonResult submitTheorderForCart(String shopCarId){
        return orderService.submitTheorderForCart(shopCarId);
    }

    /**
      * @Author: zqh
      * @Date:
      * @Description: 用户查询自己的订单
    */
    @ApiOperation(value = "用户查询自己的订单")
    @GetMapping("usersQueryTheirOrders")
    public CommonResult usersQueryTheirOrders(Integer page,Integer size){
        return orderService.usersQueryTheirOrders(page,size);
    }
    
    /**
      * @Author: zqh
      * @Date: 
      * @Description: 用户查询自己订单的数量
    */
    @ApiOperation(value = "用户查询自己订单的数量")
    @GetMapping("userGetOrdersNum")
    public CommonResult userGetOrdersNum(){
        return orderService.userGetOrdersNum();
    }
    
    /**
      * @Author: zqh
      * @Date: 
      * @Description: 店主获取店铺所有订单的数量
    */
    @ApiOperation(value = "店主获取店铺所有订单的数量")
    @GetMapping("storerGetOrdersNum")
    public CommonResult storerGetOrdersNum(){
        return orderService.storerGetOrdersNum();
    }
    
    /**
      * @Author: zqh
      * @Date: 
      * @Description: 店主分页查询订单
    */
    @ApiOperation(value = "店主分页查询自己订单")
    @GetMapping("storerGetOrdersByPage")
    public CommonResult storerGetOrdersByPage(Integer page,Integer size){
        return orderService.storerGetOrdersByPage(page,size);
    }

    /**
      * @Author: zqh
      * @Date:
      * @Description: 管理员获取所有订单数量
    */
    @ApiOperation(value = "管理员获取所有订单数量")
    @GetMapping("adminGetAllOrderNum")
    public CommonResult adminGetAllOrderNum(){
        return orderService.adminGetAllOrderNum();
    }

    /**
      * @Author: zqh
      * @Date:
      * @Description: 管理员分页查询所有订单
    */
    @ApiOperation(value = "管理员分页查询所有订单")
    @GetMapping("adminGetAllOrdersByPage")
    public CommonResult adminGetAllOrdersByPage(Integer page,Integer size){
        return orderService.adminGetAllOrdersByPage(page,size);
    }
    
    /**
      * @Author: zqh
      * @Date: 
      * @Description: 修改订单状态
    */
    @ApiOperation(value = "修改订单状态1,订单待发货，2订单以发货，3，用户已收货")
    @PostMapping("updaTheOrderStyle")
    public CommonResult updaTheOrderStyle(String orderId,Integer sty){
        return orderService.updaTheOrderStyle(orderId,sty);
    }
    
    /**
      * @Author: zqh
      * @Date: 
      * @Description: 用户取消订单
    */
    @ApiOperation(value = "用户取消订单")
    @PostMapping("userCancelsTheOrder")
    public CommonResult userCancelsTheOrder(String orderId){
        return orderService.userCancelsTheOrder(orderId);
    }

    /**
      * @Author: zqh
      * @Date:
      * @Description: 删除订单
    */
    @ApiOperation(value = "订单删除")
    @DeleteMapping("delOrderById")
    public CommonResult delOrderById(String orderId){
        return orderService.delOrderById(orderId);
    }

    /**
      * @Author: zqh
      * @Date:
      * @Description: 管理员获取被删除了的订单
    */
    @ApiOperation(value = "管理员获取被删除了的订单")
    @GetMapping("adminGelDelOrdersByPage")
    public CommonResult adminGelDelOrdersByPage(Integer page,Integer size){
        return orderService.adminGelDelOrdersByPage(page,size);
    }


}

